import re  
import urllib.request
url = "http://www.baidu.com/"  
content = urllib.request.urlopen(url).read()  
pat = b'(?<=<title>).*?(?=</title>)'
ex=re.compile(pat, re.M|re.S)
obj=re.search(ex, content)
title = obj.group()
print(str(title,'utf-8'))